from dbutils.pooled_db import PooledDB
import pymysql

from config.scaffolding_config import getMysqlConfig

mysqlConfig = getMysqlConfig()

DATABASE_CONFIG = {
    'host': mysqlConfig['host'],
    'port': int(mysqlConfig['port']),
    'user': mysqlConfig['user'],
    'password': mysqlConfig['pass'],
    'database': mysqlConfig['name'],
    'charset': 'utf8mb4',
    'cursorclass': pymysql.cursors.DictCursor
}

POOL = PooledDB(
    creator=pymysql,
    maxconnections=15,
    mincached=5,
    maxcached=15,
    maxshared=5,
    blocking=False,
    ping=1,
    **DATABASE_CONFIG
)
